setCustomAnimations
Set specific animation resources to run for the fragments that are entering and exiting in this transaction. These animations will not be played when popping the back stack.
This method applies the custom animations to all future fragment operations; previous operations are unaffected. Fragment operations in the same FragmentTransaction can set different animations by calling this method prior to each operation, e.g:
fragmentManager.beginTransaction()
.setCustomAnimations(enter1, exit1)
.add(MyFragmentClass, args, tag1) // this fragment gets the first animations
.setCustomAnimations(enter2, exit2)
.add(MyFragmentClass, args, tag2) // this fragment gets the second animations
.commit()
Parameters
An animation or animator resource ID used for the enter animation on the view of the fragment being added or attached.
An animation or animator resource ID used for the exit animation on the view of the fragment being removed or detached.
Set specific animation resources to run for the fragments that are entering and exiting in this transaction. The popEnter
and popExit
animations will be played for enter/exit operations specifically when popping the back stack.
This method applies the custom animations to all future fragment operations; previous operations are unaffected. Fragment operations in the same FragmentTransaction can set different animations by calling this method prior to each operation, e.g:
fragmentManager.beginTransaction()
.setCustomAnimations(enter1, exit1, popEnter1, popExit1)
.add(MyFragmentClass, args, tag1) // this fragment gets the first animations
.setCustomAnimations(enter2, exit2, popEnter2, popExit2)
.add(MyFragmentClass, args, tag2) // this fragment gets the second animations
.commit()
Parameters
An animation or animator resource ID used for the enter animation on the view of the fragment being added or attached.
An animation or animator resource ID used for the exit animation on the view of the fragment being removed or detached.
An animation or animator resource ID used for the enter animation on the view of the fragment being readded or reattached caused by popBackStack or similar methods.
An animation or animator resource ID used for the enter animation on the view of the fragment being removed or detached caused by popBackStack or similar methods.